![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Bug Proofing Visual Basic: A Guide to Error Handling and Prevention
Perform a PostmortemAn important but often neglected part of development is a thorough dissection of the project after its completion. You can learn a lot from the bugs encountered during development, but only if you pay close attention. Making mistakes does not automatically make you wiser. You must study the errors carefully to learn from them. During this postmortem analysis, you should determine why things went wrong and how they were fixed. Using that information, you can hopefully make fewer mistakes in the future. The following list summarizes questions you should ask about each bug.
Of course, not all of this information will be available at the end of the project unless you do a little bookkeeping during development. If a bug was introduced during design and fixed during early development, no one may remember it by the time the project is finished. Developers should keep track of the bugs as they are found and fixed. The process must be easy enough that it does not become a burden to the developers. Otherwise, they may not bother to record the bugs, or their productivity will suffer. To minimize the amount of extra work required, developers should record only bugs that make it into the projects master code. A bug that a developer writes into a new subroutine and then immediately fixes does not count. The developer should record the minimum amount of information needed to analyze the bug later. This includes where the bug is located, its description, and when it was detected. For example:
Knowing the module and routine that contains the bug, you can probably deduce who caused the bug and when, even at the end of the project. Gather this information and study it. Pay special attention to bugs that took a long time to detect or fix. Share your results with other projects. You may not be able to prevent every problem from reoccurring in another project, but you guarantee problems if you refuse to learn from past mistakes. Self-TestBecause testing is a bit different from the topics covered in previous chapters, this section does not present source code for you to evaluate. Instead, it describes an application for you to test. Figure 14.7 shows a simple calculator program named Calc. This program allows the user to enter numbers with up to 12 characters including a decimal point, plus an optional negative sign. The user can click on the buttons to perform simple arithmetic calculations. In addition to clicking buttons, the user can enter values and operators using the keyboard. The program displays the result of the calculation if the result will fit in 12 characters. If the result is too large, the program displays the string Overflow. If the value is too large a negative number, the program displays Underflow. If the user tries to divide by 0, the program displays #INF. For this self-test, design a set of black box tests for this program. Because you do not know how the application works internally, you cannot build white box tests. However, knowing the programs specification, you can probably create a set of gray box tests that search for strange special cases that might give the program trouble. For example, these tests should divide by 0, cause an overflow and underflow, and so forth.
Write the tests in English. There is little point in writing tests in Visual Basic code until you have looked at the programs source code. Appendix A, Self-Test Solutions, contains a description of tests used to find bugs in this program. You can find the source code for the program including its tests at the books Web site at www.vb-helper.com/err.htm.
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
|